// 配置
import Vue from 'vue'

import parckComponents from '@/components/ivew_components/parck_components/index'
import {intimidaTemplate, indiaTemplate} from './btnsConf'
import { deepCopy } from '../../../utils/tools';
import stateBox from '@/components/ivew_conf/state_store'

const carStateBox = new stateBox();


/*
** 按键配置方法需要与组件内定义方法对应
*/

function custom(conf){
    return {
        ...deepCopy(indiaTemplate),
        ...conf
    }
}

// 组件加载按键配置
const intimidateBtnLoadingConf = {

    //特性配置
    "jqBd": intimidaTemplate,
    "jqBz": intimidaTemplate,
    "jqFp": intimidaTemplate,
    "jqTb": intimidaTemplate,
    "jqFd": intimidaTemplate,
    "jqPd": intimidaTemplate,
    "jqJf": intimidaTemplate,

    // 商业险
    "syBd": intimidaTemplate,
    "syBk": intimidaTemplate,
    "syFp": intimidaTemplate,
    "syTb": intimidaTemplate,
    "syPd": intimidaTemplate,
}

const indiaBtnLoadingConf = {
    //特性配置
    "jqBd": custom({
        allocation: {
            component: 'l-btn-allocation',
            conf:{
                singleType: 'JQ',
                dataType: 'policys'
            }
        }
    }),
    "jqBz": custom({
        allocation: {
            component: 'l-btn-allocation',
            conf:{
                singleType: 'JQ',
                dataType: 'baoKa'
            }
        }
    }),
    "jqFp": custom({
        allocation: {
            component: 'l-btn-allocation',
            conf:{
                singleType: 'JQ',
                dataType: 'invoices'
            }
        }
    }),
    "jqTb": indiaTemplate,
    "jqFd": indiaTemplate,
    "jqPd": indiaTemplate,
    "jqJf": indiaTemplate,

    // 商业险
    "syBd": custom({
        allocation: {
            component: 'l-btn-allocation',
            conf:{
                singleType: 'SY',
                dataType: 'policys'
            }
        }
    }),
    "syBk": custom({
        allocation: {
            component: 'l-btn-allocation',
            conf:{
                singleType: 'SY',
                dataType: 'baoKa'
            }
        }
    }),
    "syFp": custom({
        allocation: {
            component: 'l-btn-allocation',
            conf:{
                singleType: 'SY',
                dataType: 'invoices'
            }
        }
    }),
    "syTb": indiaTemplate,
    "syPd": indiaTemplate,
}


// 基础信息
const baseMods = [
    {
        label: '车牌号',
        component: 'input',
        span: 8,
        conf:{
            readonly: true,
        },
        key: 'plateNo'
    },
    {
        label: '承保公司',
        component: 'input',
        span: 8,
        conf:{
            readonly: true,
        },
        key: 'viCompany'
    },
    {
        label: '请求部门',
        component: 'input',
        span: 8,
        conf:{
            readonly: true,
        },
        key: 'memberDepartment'
    },
    {
        label: '会员姓名',
        component: 'input',
        span: 8,
        conf:{
            readonly: true,
        },
        key: 'memberNickname'
    },
    {
        label: '被保人',
        component: 'input',
        span: 8,
        conf:{
            readonly: true,
        },
        key: 'assuredNickname'
    },
    {
        label: '险种概述',
        component: 'input',
        span: 8,
        conf:{
            readonly: true,
        },
        key: 'kindDesc'
    },
]

// 单证操作
const singleMods:formInf.singleModConf = {
       
    jq: {
        title: '交险单证',
        span: 12,
        mods: [
            {
                label: '保单号',
                span: 24,
                btnsConf: {},
                component: parckComponents('input'),
                conf: {
                    readonly:true,
                },
                key: 'jqBd'
            },
            {
                label: '标志',
                span: 24,
                btnsConf: {},
                component: parckComponents('input'),
                conf: {
                    readonly:true,
                },
                key: 'jqBz'
            },
            {
                label: '发票编号',
                span: 24,
                btnsConf: {},
                component: parckComponents('input'),
                conf: {
                    readonly:true,
                },
                key: 'jqFp'
            },
            {
                label: '投保单号',
                span: 24,
                btnsConf: {},
                component: parckComponents('input'),
                conf: {
                    readonly:true,
                },
                key: 'jqTb'
            },
            {
                label: '告知书',
                span: 24,
                btnsConf: {},
                component: parckComponents('input'),
                conf: {
                    readonly:true,
                },
                key: 'jqFd'
            },
            {
                label: '批单编号',
                span: 24,
                btnsConf: {},
                component: parckComponents('input'),
                conf: {
                    readonly:true,
                },
                key: 'jqPd'
            },
            {
                label: '缴费通知',
                span: 24,
                btnsConf: {},
                component: parckComponents('input'),
                conf: {
                    readonly:true,
                },
                key: 'jqJf'
            }
        ]
    },
    sy: {
        title: '商险单证',
        span: 12,
        mods: [
            {
                label: '保单号',
                span: 24,
                btnsConf: {},
                component: parckComponents('input'),
                conf: {
                    readonly:true,
                },
                key: 'syBd'
            },
            {
                label: '保卡号',
                span: 24,
                btnsConf: {},
                component: parckComponents('input'),
                conf: {
                    readonly:true,
                },
                key: 'syBk'
            },
            {
                label: '发票编号',
                span: 24,
                btnsConf: {},
                component: parckComponents('input'),
                conf: {
                    readonly:true,
                },
                key: 'syFp'
            },
            {
                label: '投保单号',
                span: 24,
                btnsConf: {},
                component: parckComponents('input'),
                conf: {
                    readonly:true,
                },
                key: 'syTb'
            },
            {
                label: '批单号',
                span: 24,
                btnsConf: {},
                component: parckComponents('input'),
                conf: {
                    readonly:true,
                },
                key: 'syPd'
            }
        ] 
    },

}

// 订单状态对应配置
const statusConf = {
    'payCach': indiaBtnLoadingConf,
    'print' : intimidateBtnLoadingConf
};


// 根据类型关键字，配置相应的操作方法， 操作方法定义在 组件内， 通过vue实例获取
function bulidConf(isIndia:string){
    
    const conf = statusConf[carStateBox.getVal(isIndia).key]

    // 集印配置
    Object.keys(singleMods).forEach(classify =>{

        singleMods[classify]['mods'].forEach(mod =>{
            mod.btnsConf = deepCopy(conf[mod.key])
        })
        
    })

    return singleMods;
}


export {

    singleMods,
    baseMods,
    bulidConf

}